home *** CD-ROM | disk | FTP | other *** search
- // Dynamic link library implementation of NeuroSolutions BackAxon component
-
- #include "NSDLL.h"
-
- /* Backpropagation of component */
-
- __declspec(dllexport) void performBackFuzzyAxon(
- DLLData *instance, // Pointer to instance data (may be NULL)
- DLLData *dualInstance, // Pointer to forward axonÆs instance data (may be NULL)
- NSFloat *data, // Pointer to the layer of processing elements (PEs)
- int rows, // Number of rows of PEs in the layer
- int cols, // Number of columns of PEs in the layer
- NSFloat *error, // Pointer to the sensitivity vector
- NSFloat *param, // Pointer to the layer of parameters for the MFs
- int paramIndex, // Index of the MF parameter
- int winnerIndex,// Index of the winning MF
- NSFloat winnerVal, // Value of the winning Input
- NSFloat *returnVal // Return value
- )
- {
- NSFloat c = *(param + winnerIndex);
- NSFloat sigma = *(param + winnerIndex + 1);
- if (sigma == 0.0f)
- *returnVal = 0.0f;
- else {
- NSFloat exp_fraction = (winnerVal - c) / sigma;
- NSFloat exp_final = (NSFloat)((exp_fraction*exp_fraction) / -2.0);
- NSFloat fwrd_activation = (NSFloat)exp (exp_final);
- if (paramIndex == winnerIndex)
- {
- NSFloat deriv_fwrd = (NSFloat)((winnerVal - c) / (sigma*sigma));
- *returnVal = fwrd_activation * deriv_fwrd;
- }
- if (paramIndex == (winnerIndex + 1)) {
- NSFloat deriv_fwrd = (NSFloat)(pow ( (winnerVal - c), 2.0) / pow (sigma, 3.0));
- *returnVal = fwrd_activation * deriv_fwrd;
- }
- }
- }
-
- /******************************************/
- /* Management of instance data (OPTIONAL) */
- /*
- __declspec(dllexport) DLLData *allocBackFuzzyAxon(
- DLLData *oldInstance, // Pointer to the last instance if reallocating
- DLLData *dualInstance, // Pointer to forward axonÆs instance data (may be NULL)
- int rows, // Number of rows of PEs in the layer
- int cols // Number of columns of PEs in the layer
- )
- {
- DLLData *instance = allocDLLInstance(oldInstance);
- return instance;
- }
-
- __declspec(dllexport) void freeBackFuzzyAxon(DLLData *instance)
- {
- freeDLLInstance(instance);
- }
- */